package elevatronic.view.right.parameter;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import elevatronic.Elevatronic;

/**
 * 
 * @author Benjamin CORNEC
 * slide control for speed, by step change
 *
 */
public class SpeedSliderStepView extends SpeedSliderView{
	private static final long serialVersionUID = -1064441535679789420L;
	public static final int INIT=0;
	
	public int getStep(){
		return Elevatronic.getSingleton().getStep();
	}
	
	public void setStep(int step){
		Elevatronic.getSingleton().setStep(step);
	}

	//save the step value
	private int stepValue;
	public int getStepValue() {
		return stepValue;
	}
	public void setStepValue(int stepValue) {
		this.stepValue = stepValue;
	}
	
	
	public SpeedSliderStepView(int width, int height) {
		super(width, height,0, 100, INIT);
		
		
		addChangeListener(new ChangeListener() {
			@Override
			public void stateChanged(ChangeEvent arg0) {
				int step=convert(getValue());
				setStepValue(step);
				setStep(step);
				
			}
	    });
	}
	

	
	public static int convert(int _value){		
		return _value*_value+1;
	}


	
}
